//
//  SearchResultsViewController.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/4/29.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "SearchResultsViewController.h"
#import "TraderMoneyDetailCell.h"
#import "StoreMoneyCell.h"
#import "StroeMoneyViewController.h"

@interface SearchResultsViewController ()<UITableViewDataSource,UITableViewDelegate,traderMoneyDetailCellDelegate>

@property (weak, nonatomic) IBOutlet UILabel *lab1;
@property (weak, nonatomic) IBOutlet UILabel *lab2;
@property (weak, nonatomic) IBOutlet UILabel *lab3;

@end

@implementation SearchResultsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavigationTitle];
    [self addTableView];
    [self addSearchBarView];
    [self setLabs];
}

#pragma mark 设置导航栏的标题
-(void)setNavigationTitle
{}

#pragma mark 设置lab1,lab2,lab3
-(void)setLabs
{
    if (self.seachResultType == searchByTime || self.seachResultType == searchByStore)
    {
        self.lab1.text = @"佣金比例(%)";
        self.lab2.hidden = NO;
        self.lab2.text = @"预计佣金(美元)";
        self.lab3.text = @"实际佣金(美元)";
        
        
        
       
    }else if(self.seachResultType == searchByMiddleMan)
    {
        self.lab1.text = @"经纪人";
        self.lab2.hidden = YES;
        self.lab3.text = @"佣金";
    }else
    {
        self.lab1.text = @"门店名称";
        self.lab3.text = @"佣金";
        self.lab2.hidden = YES;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)addTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 253, UIScreenWidth, UIScreenHeight - 253) style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
      if (self.seachResultType == searchByTSite || self.seachResultType == searchByTime)
      {
          self.tableView.allowsSelection = NO;
      }
    else
    {
        self.tableView.allowsSelection = YES;
    }
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.seachResultType == searchByTSite || self.seachResultType == searchByTime)
    {
        TraderMoneyDetailCell *cell = [TraderMoneyDetailCell cellWithTableView:tableView];
        cell.delegate = self;
        return cell;
        
    }else
    {
        return [StoreMoneyCell cellWithTableView:tableView];
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.seachResultType == searchByTSite || self.seachResultType == searchByTime)
    {
        return 174;
    }else
    {
        return 44;
    }

}


#pragma mark traderMoneyDetailCell的代理，响应点击了“经纪人名称”或者“门店名”
-(void)traderMoneyDetailCellClickBtnWithBtnTag:(NSInteger)btnTag
{
    StroeMoneyViewController *vc = [[StroeMoneyViewController alloc]initWithNibName:@"StroeMoneyViewController" bundle:nil];
    
    if (btnTag == 0)
    {
        vc.viewFlag = isPersonalMoneyView;
    }
    else
    {
        vc.viewFlag = isMiddleManMoneyOfStoreView;
    }
    
    [self.navigationController pushViewController:vc animated:YES];
}


@end
